package util

import "github.com/zclconf/go-cty/cty"

//CloneStringList Make a copy of the given list of strings
func CloneStringList(listToClone []string) []string {
	out := []string{}
	for _, item := range listToClone {
		out = append(out, item)
	}
	return out
}

//CloneStringMap Make a copy of the given map of strings
func CloneStringMap(mapToClone map[string]string) map[string]string {
	out := map[string]string{}
	for key, value := range mapToClone {
		out[key] = value
	}
	return out
}

func CloneValueMap(m map[string]cty.Value) map[string]cty.Value {
	nm := map[string]cty.Value{}
	for k, v := range m {
		nm[k] = v
	}
	return nm
}

func Merge(a, b map[string]cty.Value) map[string]cty.Value {
	c := make(map[string]cty.Value, 0)
	for k, v := range CloneValueMap(a) {
		c[k] = v
	}
	for k, v := range CloneValueMap(b) {
		c[k] = v
	}
	return c
}

func MergeMapString(a, b map[string]string) map[string]string {
	c := make(map[string]string, 0)
	for k, v := range CloneStringMap(a) {
		c[k] = v
	}
	for k, v := range CloneStringMap(b) {
		c[k] = v
	}
	return c
}
